<!DOCTYPE html >

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Pagination 分页表格</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	
    
    <script src="__PUBLIC__/scripts/boot.js" type="text/javascript"></script>
      
        
</head>

<body>
<present name="newmail">
<h1>未读消息</h1>     
<div style="padding-bottom:5px;">
        
<span>发件人姓名：</span><input type="text" id="key"  />
<input type="button" value="查找" onclick="search()"/>
         </div>
<div id="datagrid1" class="mini-datagrid" style="width:800px;height:180px;" 
    url="__APP__/Mail/query"  idField="id" allowResize="true"
    sizeList="[10,20,30,50,100]" pageSize="10"  
>
    <div property="columns">
        <div type="indexcolumn" >序号</div>
        <div field="sendname" width="120" headerAlign="center" allowSort="true">发件人姓名</div>    
        <div field="title" width="120" headerAlign="center" allowSort="true">主题</div> 
		<div field="content" width="120" headerAlign="center" allowSort="true">内容</div> 		
        <div field="senddate" width="100" headerAlign="center"  allowSort="true" dateFormat="yyyy-MM-dd">发送日期</div>     
		<div name="action" width="120" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;">操作</div>		
    </div>
</div>   


 <iframe id="exportIFrame" style="display:none;"></iframe>

<div id="win1" class="mini-window" title="详细内容" style="width:800px;" 
    showMaxButton="true" 
    showToolbar="true" showFooter="true" showModal="true" allowResize="true" allowDrag="true"
    >

<fieldset style="width:700px;border:solid 1px #aaa;margin-top:8px;position:relative;">
        <legend>详细信息</legend>
        <div id="editForm1" style="padding:5px;">
            <input class="mini-hidden" name="id"/>
            <table style="width:100%;">
                <tr>
                    <td style="width:80px;">发件人姓名</td>
                    <td style="width:150px;"><input id="sendname" name="sendname" class="mini-textbox" /></td>
                </tr>
				<tr>
					<td style="width:80px;">发送日期</td>
                    <td style="width:150px;"><input name="senddate" class="mini-textbox" /></td>
				</tr>
                <tr>
                    <td>主题：</td>
                    <td><input id="title" name="title" class="mini-textbox" /></td>
               </tr>
			   <tr>
                    <td>内容：</td>
                    <td><input id="content" name="content" class="mini-textarea"  style="width:400px;height:300px"/></td>
               </tr>
            </table>
        </div>
</fieldset>
    </div>

</present>


      <h1>项目列表</h1>      
 <div style="padding-bottom:8px;">
        <select id="select1" onchange="onStateChange(this.value)">
            <option value="所有" selected>所有</option>
            <option value="活跃">活跃</option>  
            <option value="休眠">休眠</option> 
            <option value="退出">退出</option> 
        </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      
 </div>  

<div id="datagrid2" class="mini-datagrid" style="width:800px;height:500px;" 
    url="__APP__/Project/query"  idField="id" allowResize="true"
    sizeList="[20,30,50,100]" pageSize="20"  showFilterRow="true" 
>
    <div property="columns">
        <div width="40" type="indexcolumn" >序号</div>
        <div field="pname" width="100" headerAlign="center" allowSort="true">项目名
            <input id="pnameFilter" property="filter" class="mini-textbox" onvaluechanged="onpnameFilterChanged" style="width:100%;" /></div>    
        <div field="managername" width="100" headerAlign="center" allowSort="true">项目经理
         <input id="managernameFilter" property="filter" class="mini-textbox" onvaluechanged="onmanagernameFilterChanged" style="width:100%;" /></div> 
        <div field="partnername" width="100" headerAlign="center" allowSort="true">主管合伙人
            <input id="partnernameFilter" property="filter" class="mini-textbox" onvaluechanged="onpartnernameFilterChanged" style="width:100%;" /></div>       
        <div field="regdate" width="100" headerAlign="center"  allowSort="true" dateFormat="yyyy-MM-dd">入库日期</div>  
        <div field="fund" width="100" headerAlign="center"  allowSort="true">拟投基金主体
            <input id="fundFilter" property="filter" class="mini-textbox" onvaluechanged="onfundFilterChanged" style="width:100%;" /></div>         
        <div field="postfund" width="150" headerAlign="center" >已投基金主体</div>
		<div field="state" width="80" headerAlign="center"  allowSort="true">状态</div>      
    </div>
</div>
    <script type="text/javascript">

    
        mini.parse();       

        var grid2 = mini.get("datagrid2");
   
        grid2.load({ state: "所有"});
        
        grid2.on("rowclick", function (e) {
             //alert(e.record.mid);//弹个ID出来就好了
            //window.location.href="__APP__/Project/toinfo?pid="+e.record.pid;
            var url="__APP__/Project/toinfo?pid="+e.record.pid;
            window.parent.selectproject(url);
            //showWindow();
         });


        function onStateChange(value) {   
            //mini.alert(value);
            grid.load({ state: value});
        }
        
        //对"createtime"字段，进行降级排序
        grid2.sortBy("state", "desc");



  
    
        
    

        ///////////

        var grid = mini.get("datagrid1");
   
        grid.load({ state: 0});
		
		grid.on("rowdblclick", function (e) {
              //alert(e.record.mid);//弹个ID出来就好了	
			  if(e.record.state=="0")
			   $.ajax({
                        url: "__APP__/Mail/read?mid=" + e.record.mid,
                        success: function (text) {
							
                        },
                        error: function () {
                        }
                    });
					
					showWindow();
         });
		
        var db = new mini.DataBinding();
        db.bindForm("editForm1", grid);
		
		function showWindow() {
			var win = mini.get("win1");
			win.show();
		}

        
        //对"createtime"字段，进行降级排序
        grid.sortBy("mid", "desc");

        function search() {
            var key = document.getElementById("key").value;
            grid.load({ key: key , state:0});
        }

        ///////////////////////////////////////////////////////
		function onActionRenderer(e) {
            var grid = e.sender;
            var record = e.record;
            var uid = record._uid;
            var rowIndex = e.rowIndex;

            var s = ' <a class="Edit_Button" href="javascript:reply(\'' + uid + '\')">回复</a>'
                    + ' <a class="Delete_Button" href="javascript:delRow(\'' + uid + '\')">删除</a>';         
            return s;
        }
		function reply(row_uid){
			var row = grid.getRowByUID(row_uid);
			window.location.href="__APP__/Mail/sendmail?sendname="+row.sendname+"&title="+row.title;
			
		
		}
		function delRow(row_uid) {
            var row = grid.getRowByUID(row_uid);
			
            if (row) {
                if (confirm("确定删除此记录？")) {
                    grid.loading("删除中，请稍后......");
                    $.ajax({
                        url: "__APP__/Mail/delete?mid=" + row.mid,
                        success: function (text) {
							
                            grid.reload();
                        },
                        error: function () {
                        }
                    });
                }
            }
        }
		function onmanagernameFilterChanged(e) {
        var textbox = e.sender;
        var key = textbox.getValue();
        var state=document.getElementById("select1").value;
        grid2.load({ managername: key, state:state});
        }
        function onpartnernameFilterChanged(e) {
        var textbox = e.sender;
        var key = textbox.getValue();
        var state=document.getElementById("select1").value;
        grid2.load({ partnername: key, state:state});
        }
         function onfundFilterChanged(e) {
        var textbox = e.sender;
        var key = textbox.getValue();
        var state=document.getElementById("select1").value;
        grid2.load({ fund: key, state:state});
		
        }
         function onpnameFilterChanged(e) {
        var textbox = e.sender;
        var key = textbox.getValue();
        var state=document.getElementById("select1").value;
        grid2.load({ pname: key, state:state});
        }
        function onStateChange(value) {   
            
            grid2.load({ state: value});
        }
		function ExportExcel() {
            var columns = grid.getBottomColumns();
            
            function getColumns(columns) {
                columns = columns.clone();
                for (var i = columns.length - 1; i >= 0; i--) {
                    var column = columns[i];
                    if (!column.field) {
                        columns.removeAt(i);
                    } else {
                        var c = { header: column.header, field: column.field };
						//mini.alert(column.field);
                        columns[i] = c;
                    }
                }
                return columns;
            }
            
            var columns = getColumns(columns);
            var json = mini.encode(columns);
			//mini.alert(columns);
            var url = "__URL__/export?columns=" + encodeURI(json);
            var exportIFrame = document.getElementById("exportIFrame");
            exportIFrame.src = url;

        }
		
	function CloseWindow(action) {

        if (window.CloseOwnerWindow) window.CloseOwnerWindow(action);

        else window.close();

    	}
    </script>

    


  

</body>
</html>